1. Field of the Invention
The present invention generally relates to processing threads in multithreaded environments.
2. Background Art
In some processing systems, multiple threads can be executed concurrently. When the system includes a single processor, the multiple threads can be executed by switching between threads in a time-division multiplexed manner. In multiple processor systems, each processor can concurrently execute one or more threads.
When multiple threads access a common resource, synchronization problems may arise. For example, if multiple threads access a global variable, the first thread cannot proceed to operate on the global variable until the final thread that needs to read the global variable at its current state has accessed the global variable. In existing systems a flag can be used to indicate to the first thread that the final thread has accessed the common resource. For example, the final thread can set this flag after it has accessed the global variable. Once the flag has been set, the first thread can proceed to operate on the global variable. In these systems, however, the first thread, and subsequent threads that precede the final thread, must remain active to check the state of the flag. These active threads occupy valuable processing time that could be used by other threads, leading to both wasted power and decreased performance.
Thus, what is needed are methods and systems that allow for multiple threads to synchronously access a common resource without wasting processing time by repeatedly checking the state of a flag associated with the resource.